<template>
	<view class="new_page">
		<view class="main">
			<!-- tag -->
			<view class="tag_wrap">
				<view class="tag_item" v-for="(item,index) in tagList" :key="index" @click="typeChange(index)"
					:class="{'active':activeIndex==index}">
					<text>{{item}}</text>
				</view>
			</view>
			
			<view class="search_wrap" v-if="activeIndex==0">
				<view class="search">
					<input v-model="searchValue" :placeholderStyle="placeholderStyle" placeholder="输入手机号或订单号后6位"></uni-easyinput>
				</view>
				<view class="">
					<button class="b-bg b-ligth-bg" @click="search">确定</button>
				</view>
			</view>
			
			
			<!-- 表单 -->
			<view class="list_wrap">
			<!-- 	<swiper :indicator-dots="false" :autoplay="false" :interval="4000"
					:duration="500" @change="handleChange" 	:current="activeIndex" style="height: 100%"> -->
					<view v-for="(item,index) in tagList" :key="index">
						<!-- <swiper-item  style="overflow: auto"> -->
							<view class="swiper-item" v-if="activeIndex==index">
								<view class="item_content">
									<view class="row title_wrap">
										<view class="title row_item" v-for="(title,i) in titleList" :key="i">
											<text>{{title}}</text>
										</view>
									</view>
									<view class="row"  v-for="(order,i) in orderList" :key="i">
										<view class="row_item no-wrap">
											{{order.orderId}}
										</view>
										<view class="row_item">
											<view class="user_info">
												<view>
													{{order.nickName}}
												</view>
												<text>{{order.phoneNumber}}</text>
											</view>
											
										</view>
										<view class="row_item">
											{{order.orderDateTime}}
										</view>
										<view class="row_item">
											<text class="uni-primary bg-text" v-if="order.orderStatus=='A'" @click="orderhx(order.orderId)">确认核销</text>
										    <text v-if="order.orderStatus=='V'">已核销</text>
										</view>
									</view>
								</view>
							</view>
						<!-- </swiper-item> -->
					</view>
				<!-- </swiper> -->
			</view>
		
			
		</view>
	</view>
</template>

<script>
	import { orderslist,orderhx } from '@/request/api.js'
	import { toast,useRouter } from '@/request/utils.js'
	export default {
		data() {
			return {
				placeholderStyle: "font-size: 30rpx;",
				activeIndex: 0,
				tagList: [
					'核销订单',
					'核销记录'
				],
				titleList: [
					'订单编号',
					'用户',
					'支付时间',
					'操作'
				],
				orderList: [],
				searchValue: ''
			}
		},
		onLoad() {
			this.orderslist('A')
		},
		methods: {
			async search(e) {
				let name = this.searchValue
				let arr = this.arr
				let a =this.activeIndex
				let status = 'A'
				let res = await orderslist({orderStatus:status,nums:name})
				if(res.code==200){
					this.orderList = res.data
				}else{
					toast(res.message)
				}
			},
			typeChange(e){
				console.log(e)
				this.activeIndex = e
				if(e==0){
					this.orderslist('A')
				}else{
					this.orderslist('V')
				}
			},
			async orderhx(id){
				let res = await orderhx({id:id})
				if(res.code==200){
					this.goToNoLoginPage('/pagesA/success/success','navigateTo');
				}else{
					toast(res.message)
				}
			},
			
			async orderslist(status){
				let res = await orderslist({orderStatus:status})
				if(res.code==200){
					this.orderList = res.data
				}
			},
			
			handleChange(e){
				this.activeIndex = e.detail.current;
			}
			
		}
	}
</script>

<style lang="scss" scoped>
	.b-ligth-bg {
		background-color: #7996ef;
		border-radius: 0;
	}
	.bg-text {
		color: #FFFFFF;
		background: #476FF2;
		padding: 4rpx 10rpx;
	}
.new_page {
	padding-top: 30rpx;
	height: 100%;
	box-sizing: border-box;
	.main {
		background-color: #fff;
		border-radius: 14rpx;
		padding: 40rpx 30rpx 0;
		display: flex;
		flex-direction: column;
		.tag_wrap {
			display: flex;
			align-items: center;
		
			.tag_item {
				position: relative;
				
				font-size: 25rpx;
				color: $text-grey;
				padding: 6rpx 20rpx;
				margin: 30rpx 0;
		
				&.active {
					color: $uni-primary;
					font-size: 29rpx;
		
					&::after {
						content: "";
						position: absolute;
						left: 0;
						right: 0;
						bottom: -4rpx;
						margin: auto;
						width: 50%;
						height: 2px;
						background-color: $uni-primary;
					}
				}
			}
		}
	
		.search_wrap {
			padding: 40rpx 20rpx;
			margin: 50rpx 0 0;
			display: flex;
			justify-content: center;
			align-items: stretch;
			background-color: #eee;
			
			.search {
				width: 70%;
				margin-right: 20rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				border: 1px solid #222;
			}
		}
		
		.list_wrap {
			margin-top: 50rpx;
			box-sizing: border-box;
			border: 1px solid #C4C4C4;
			border-radius: 7rpx;
			.item_content {
				margin: auto;
				.title_wrap {
					background-color: #d8d8d8 !important;
					font-size: 29rpx;
					border-radius: 7rpx 7rpx 0 0;
				}
				.row {
					display: flex;
					justify-content: space-between;
					align-items: stretch;
					background-color: #E9E9E9;
					font-size: 22rpx;
					.row_item:nth-child(n+2) {
						border-left: 1px solid #C4C4C4;
					}
				}
				
				.row:nth-child(2n){
					background-color: #fff;
				}
				.row_item {
					flex: 1;
					padding: 20rpx 0;
					display: flex;
					justify-content: center;
					align-items: center;
					font-size: 26rpx;
					text-align: center;
					.user_info {
						display: flex;
						flex-direction: column;
						justify-content: center;
						align-items: center;
					}
					.ml {
						margin-left: 10rpx;
					}
				}
			}
		}
		
	
	}
}
</style>
